package com.Web_02;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet(name = "UserAgentRequest", value = "/UserAgentRequest")
public class UserAgentRequest extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//      获取浏览器的版本信息
        String userAgent=request.getHeader("user-agent");
//        判断浏览器版本
        if (userAgent.contains("Chrome")){
            System.out.println("浏览器：谷歌");
        } else if (userAgent.contains("FirFox")) {
            System.out.println("浏览器：火狐");

        } else if (userAgent.contains("Edge")) {
            System.out.println("浏览器：edge");
        }else {
            System.out.println("浏览器：其他");
        }
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
